from typing import List

from FileHandlers.JsonFile import JReadSave, JWriteSave
from playerData.Preinstall.Home import moonlight, robbers_home, snowGodHome, Home, kingdom

from dataclasses import dataclass, asdict, field


def init_resorce(save_name, diff=None, saveJson=None):
    resource_data = diffcult_resource_init.get(diff)
    resource_data['saveJson'] = saveJson

    JWriteSave(saveName=save_name, filename="player-data", data=resource_data)


@dataclass
class player_data:
    saveJson: dict = field(default_factory=dict)
    Home: List[Home] = field(default_factory=list)
    Money: int = field(default=20)
    Auths: list = field(default_factory=list)
    Where: str = field(default='home')


diffcult_resource_init = {
    "贫困潦倒的旧贵族": asdict(player_data(Home=[asdict(moonlight)], Money=400, Auths=['达尔国的贵族'])),
    "游手好闲的街溜子": asdict(player_data(Home=[asdict(robbers_home)], Auths=['盗贼团二把手'])),
    "雪神宫的仆人": asdict(player_data(Home=[asdict(snowGodHome)], Auths=['雪神宫的领导者'])),
    "世界至高王": asdict(player_data(Home=[asdict(kingdom)], Auths=["至高王"])),
    "百米巨大娘秋丽艾尔": asdict(player_data(Home=[], Auths=["巨大娘"])),
}

diffcult_resource_method = {
    "简单": {
        "methods": {
            "init": [],
        },
    },
    "普通": {
        "methods": {
            "init": [],
        },
    },
    "困难": {
        "methods": {
            "init": [],
        },
    }
}

"""
------------------------------------------------------------------
预渲染机制文本:
    $POINT_DY$ - 当前point所属的国家                               
    
------------------------------------------------------------------
"""


@dataclass
class point_config:
    """
    这里的信息就是地图的简介可以看到的
    """
    描述: str

    def dict(self):
        return asdict(self)

"""
# ------------------
第三方修改事宜
{
    国家: {
        城市名称: {
            交互点: {
                功能: 对应函数
                ...
            }
            ...
        }
        ...
    }
}

# --------------- 城市名称、国家的不能重复 但是交互点可以重复
"""
default_maps = {
    "塞达尔国": {
        "塞达尔中心公园": {
            "湖心船舶": {
                "划船": "1",  # 这里的编号对应的是 entiys.methods里面的分发方法 方法的注册在 `entiy.methods.MapDispatch` 进行配置
                "购买出租点": "2",
                "设置管理者": "3",
                "查看经营数据": "4",
                "和这里的奴隶主聊天": "5",
                "和这里的经营者做爱": "6"
            },
            "中心森林": {
                "让...进行虫交": "7",
                "用树枝抽打...": "8"
            },
            "config": point_config(描述="这里是$POINT_DY$的中心公园里面很热闹").dict()
        },
        "塞达尔街道": {

        },
        "国都": {}
    },
    "木达": {
        "贫民窟": {
            "屠夫菜市场": {
                "处决...": "9",
                "天才制奶厂(只做人奶哦)": "10"
            }
        },
        "盛山洞": {}
    },
    "雪神宫": {
        "雪神宫": {},
        "雪神山": {}

    },
    "宣朝": {
        "凌波村": {},
        "药师坛": {},
        "琦玖部落": {},
        "六道回": {}

    },
    "秋丽艾尔": {'秋丽艾尔': {}},
}  # 初始地图


